#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
int main()
{
    int n = 0;
    scanf("%d", &n);
    int arr[50] = { 0 };
    int i = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
    }
    int x = 0;
    scanf("%d", &x);
    for (i = 0; i < n; i++)
    {

        if (arr[i] > x)
        {
            int m = n;
            while (m - i)
            {
                arr[m] = arr[m - 1];
                m--;
            }
            arr[i] = x;
            break;
        }
        if (arr[n - 1] < x)
        {
            arr[n] = x;
        }

    }
    for (i = 0; i < n + 1; i++)
    {
        printf("%d ", arr[i]);
    }
    return 0;
}